package thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author pedant
 * @Date 2019/8/30 15:34
 * @Description 创建线程的方式
 */
public class CallableTest implements Callable<String> {

    @Override
    public String call() throws Exception {
        return Thread.currentThread().getName()+"线程启动";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> future = new FutureTask<>(new CallableTest());
        new Thread(future,"callable").start();
        System.out.println(future.get());
    }
}
